#pragma once
#include "Config.h"

/**
* @brief only store valid global valid tmp values
* @note must not include functional class! be global pure
*/
class Global {
public:
	static void increaseFrameCnt() {
		++s_frameCnt;
		if (s_frameCnt % Config::Marker_Ellipse_BlinkFrameGap == 0)
			s_isBlinkingOn = !s_isBlinkingOn;
	}

	static UInt frameCnt() { return s_frameCnt; }

	static bool isBlinkingOn() { return s_isBlinkingOn; }

	static void updateDashedVOffset(float zhicheSpeed) {
		const auto D = Config::Line_VSpeedFactor;// zhicheSpeed factor
		if (zhicheSpeed <= 0.1) {// Zhiche still
			s_dashedVOffset = 0;
			N1 = N2 = N3 = N4 = N5 = 0;
		} else if (zhicheSpeed > 0.1 && zhicheSpeed <= 18) {
			s_dashedVOffset = 1 * D * (++N1);
			N2 = N3 = N4 = N5 = 0;
		} else if (zhicheSpeed > 18 && zhicheSpeed <= 36) {
			s_dashedVOffset = 2 * D * (++N2);
			N1 = N3 = N4 = N5 = 0;
		} else if (zhicheSpeed > 36 && zhicheSpeed <= 72) {
			s_dashedVOffset = 3 * D * (++N3);
			N1 = N2 = N4 = N5 = 0;
		} else if (zhicheSpeed > 72 && zhicheSpeed <= 108) {
			s_dashedVOffset = 4 * D * (++N4);
			N1 = N2 = N3 = N5 = 0;
		} else if (zhicheSpeed > 108) {
			s_dashedVOffset = 5 * D * (++N5);
			N1 = N2 = N3 = N4 = 0;
		}

		if (s_dashedVOffset == Config::Line_Dashed_SegLen + Config::Line_Dashed_SegInterval)// reset
			N1 = N2 = N3 = N4 = N5 = 0;
	}

	inline static float dashedVOffset() { return s_dashedVOffset; }

	inline static void setDarkMode(bool isDarkMode) { s_isDarkMode = isDarkMode; }
	inline static bool isDarkMode() { return s_isDarkMode; }

private:
	Global() = default;

	static float s_dashedVOffset;
	static int N1, N2, N3, N4, N5;

	static UInt s_frameCnt;
	static bool s_isBlinkingOn;

	static bool s_isDarkMode;
};